package com.demo.java.OD51_100.OD61;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author bug菌
 * @Source 公众号：猿圈奇妙屋
 * @des： 【求字符串中所有整数的最小和】问题
 * @url： https://blog.csdn.net/weixin_43970743/article/details/145601552
 */
public class OdMain {
    public static void sovle(String values) {
        boolean fuNumber = false;
        String tempNumber = "-";
        List<Integer> myList = new ArrayList<>();
        for (int j = 0; j < values.length(); ++j) {
            char tem = values.charAt(j);
            if (tem == '-') {
                fuNumber = true;
                continue;
            }
            if (tem <= '9' && tem >= '0') {
                if (fuNumber) { //如果不是字符就一直往下记录
                    tempNumber += tem;
                } else {
                    myList.add(Integer.parseInt(String.valueOf(tem)));
                }
            } else {
                if (tempNumber != "-") {
                    myList.add(Integer.parseInt(tempNumber));
                    tempNumber = "-";
                }
                fuNumber = false;
            }
        }
        int sum = 0;
        for (int j = 0; j < myList.size(); ++j) {
            sum += myList.get(j);
        }
        System.out.println(sum);
    }

    public static void main(String[] args) {
        try {
            Scanner s = new Scanner(System.in);
            String values = s.nextLine();
            sovle(values);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("input error");
        }
    }

}